public class Waiter implements Runnable{
    private Orders orders;
    private Chef chef;
    private int msgID = 1;

    public void setMsgID (int msgID){
        this.msgID = msgID;
    }

    public void setOrders(Orders orders){
        this.orders = orders;
    }
    public void setChef(Chef chef) {
        this.chef = chef;
    }

    @Override
    public void run() {
        while (true){
            synchronized (this){
                try {
                    System.out.println("服务员空闲中+++++++++++");
                    this.wait();

                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            if(msgID==1){
                System.out.println("waiter收到订单"+this.orders.getDno()+","+this.orders.getInfo());
                synchronized (chef){
                    System.out.println("waiter 通知厨师做菜+++++++++++");
                    chef.setOrders(orders);
                    chef.notify();
                }
            }else if(msgID==2) {
                System.out.println("服务员取完菜，送给客户+++++++++++");
            }
        }

    }

}
